package com.gitee.theskyzero.boot.web.controller;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

@RestController("controllerBeanName")
@RequestMapping(path = "/test")
public class TestRestController {

    @GetMapping("/{variable}")
    public String testGet(@PathVariable String variable, @RequestParam String param) {
        return "test get success: variable=" + variable + ", param=" + param;
    }

    @PostMapping
    public String testPost(@RequestBody String data) {
        return "test post success: data=" + data;
    }

    @PutMapping("/{variable")
    public String testPut(@PathVariable String variable, @RequestBody String data) {
        return "test put success: variable=" + variable + ", data=" + data;
    }

    @DeleteMapping("/{variable")
    public String testDelete(@PathVariable String variable) {
        return "test delete success: variable=" + variable;
    }

    @RequestMapping("/other")
    @ResponseStatus(code = HttpStatus.OK, reason = "响应成功")
    @ResponseBody
    public String testOther(@RequestHeader String header, @RequestAttribute String attribute) {
        return "test other success: header=" + header + ", attribute=" + attribute;
    }
}
